<?php

namespace Admin\Models\bpm;

use Helpers\Main;

class XHBpmPlanContent extends basicModel
{

    /**
     *
     * @var integer
     * @Primary
     * @Identity
     * @Column(type="integer", length=11, nullable=false)
     */
    public $iBPCId;

    public $bLock;
    
    public $iType;

    public $iNodeState;
    /**
     *
     * @var integer
     * @Column(type="integer", length=11, nullable=true)
     */
    public $iBPPId;

    /**
     *
     * @var string
     * @Column(type="string", length=255, nullable=true)
     */
    public $sNodeName;

    /**
     *
     * @var string
     * @Column(type="string", length=255, nullable=true)
     */
    public $sExcuteDeps;

    /**
     *
     * @var string
     * @Column(type="string", length=255, nullable=true)
     */
    public $sExcuteIds;

    /**
     *
     * @var string
     * @Column(type="string", length=255, nullable=true)
     */
    public $sRelatDeps;

    /**
     *
     * @var string
     * @Column(type="string", length=255, nullable=true)
     */
    public $sRelatIds;

    /**
     *
     * @var string
     * @Column(type="string", nullable=true)
     */
    public $tPlanDate;

    /**
     *
     * @var string
     * @Column(type="string", length=255, nullable=true)
     */
    public $sQueDesc;

    /**
     *
     * @var string
     * @Column(type="string", length=255, nullable=true)
     */
    public $sSolution;

    /**
     *
     * @var string
     * @Column(type="string", length=50, nullable=true)
     */
    public $sExcProcess;

    /**
     *
     * @var string
     * @Column(type="string", nullable=true)
     */
    public $tRealDate;

    /**
     *
     * @var integer
     * @Column(type="integer", length=11, nullable=true)
     */
    public $iChargeId;

    /**
     *
     * @var string
     * @Column(type="string", nullable=true)
     */
    public $mDesc;

    /**
     *
     * @var integer
     * @Column(type="integer", length=11, nullable=true)
     */
    public $iSort;

    /**
     *
     * @var string
     * @Column(type="string", length=255, nullable=true)
     */
    public $retain1;

    /**
     *
     * @var string
     * @Column(type="string", length=255, nullable=true)
     */
    public $retain2;

    /**
     *
     * @var string
     * @Column(type="string", length=255, nullable=true)
     */
    public $retain3;

    /**
     *
     * @var integer
     * @Column(type="integer", length=1, nullable=true)
     */
    public $bDelete;

    /**
     *
     * @var string
     * @Column(type="string", nullable=true)
     */
    public $tCreateDate;

    /**
     *
     * @var integer
     * @Column(type="integer", length=20, nullable=true)
     */
    public $iCreateUserId;

    /**
     *
     * @var string
     * @Column(type="string", nullable=true)
     */
    public $tLastModifyDate;

    /**
     *
     * @var integer
     * @Column(type="integer", length=20, nullable=true)
     */
    public $iLastModifyUserId;

    /**
     * Initialize method for model.
     */
    public function initialize()
    {
        $this->keepSnapshots(true);
        $this->setSource("XHBpm_PlanContent");
    }

    /**
     * Returns table name mapped in the model.
     *
     * @return string
     */
    public function getSource()
    {
        return 'XHBpm_PlanContent';
    }

    /**
     * Allows to query a set of records that match the specified conditions
     *
     * @param mixed $parameters
     * @return XHBpmPlanContent[]|XHBpmPlanContent|\Phalcon\Mvc\Model\ResultSetInterface
     */
    public static function find($parameters = null)
    {
        return parent::find($parameters);
    }

    /**
     * Allows to query the first record that match the specified conditions
     *
     * @param mixed $parameters
     * @return XHBpmPlanContent|\Phalcon\Mvc\Model\ResultInterface
     */
    public static function findFirst($parameters = null)
    {
        return parent::findFirst($parameters);
    }

    public function beforeUpdate()
    {
//        var_dump($this->hasChanged('sNodeName')||$this->hasChanged('sExcuteDeps')||$this->hasChanged('sExcuteIds')||$this->hasChanged('sRelatIds')||$this->hasChanged('sRelatDeps')||$this->hasChanged('iSort'));die();
//        if($this->hasChanged('sNodeName')||$this->hasChanged('sExcuteDeps')||$this->hasChanged('sExcuteIds')||$this->hasChanged('sRelatIds')||$this->hasChanged('sRelatDeps')||$this->hasChanged('iSort')){
//
//        }else{
//            if(!$this->hasChanged('iType')&&!$this->hasChanged('bLock')){

//            }
//
//        }
        if($this->hasChanged('tPlanDate')||$this->hasChanged('tRealDate')||$this->hasChanged('sExcProcess')||$this->hasChanged('iChargeId')||$this->hasChanged('sQueDesc')||$this->hasChanged('sSolution')||$this->hasChanged('mDesc')||$this->hasChanged('bNotify')||$this->hasChanged('sOtherPhone')){
            if($this->hasChanged('tRealDate')){
                $this->sExcProcess=100;
            }
            $date=date('Y-m-d H:i:s', time());
            $id=Main::getLoginUserInfo('userId');
            $this->tLastModifyDate=$date;
            $this->iLastModifyUserId=$id;

        }
        //var_dump($this->hasChanged('sExcuteDeps'));die();

    }

}
